package com.cysyz.mylib.hibernatedao;


import com.cysyz.mylib.dao.engine.ClassMetadata;
import org.hibernate.EntityMode;
import org.hibernate.HibernateException;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.type.Type;

import java.io.Serializable;
import java.util.Map;

/**
 * Created by jiaoyujia on 2015/2/9.
 */
public class ClassMetadataHibernate implements ClassMetadata {

    private final org.hibernate.metadata.ClassMetadata classMetadata;

    public ClassMetadataHibernate(org.hibernate.metadata.ClassMetadata classMetadata) {
        this.classMetadata = classMetadata;
    }

    @Override
    public String getEntityName() {
        return classMetadata.getEntityName();
    }

    public void setIdentifier(Object entity, Serializable id, EntityMode entityMode) throws HibernateException {
        classMetadata.setIdentifier(entity, id, entityMode);
    }

    @Override
    public String[] getPropertyNames() {
        return classMetadata.getPropertyNames();
    }

    @Override
    public boolean[] getPropertyLaziness() {
        return classMetadata.getPropertyLaziness();
    }

    @Override
    public boolean hasSubclasses() {
        return classMetadata.hasSubclasses();
    }

    @Override
    public String getIdentifierPropertyName() {
        return classMetadata.getIdentifierPropertyName();
    }

    @Override
    public boolean[] getPropertyNullability() {
        return classMetadata.getPropertyNullability();
    }

    public Type getPropertyType(String propertyName) throws HibernateException {
        return classMetadata.getPropertyType(propertyName);
    }

    public Object instantiate(Serializable id, SessionImplementor session) {
        return classMetadata.instantiate(id, session);
    }

    public boolean implementsLifecycle(EntityMode entityMode) {
        return classMetadata.implementsLifecycle(entityMode);
    }

    @Override
    public int[] getNaturalIdentifierProperties() {
        return classMetadata.getNaturalIdentifierProperties();
    }

    public void setIdentifier(Object entity, Serializable id, SessionImplementor session) {
        classMetadata.setIdentifier(entity, id, session);
    }

    public Object[] getPropertyValuesToInsert(Object entity, Map mergeMap, SessionImplementor session) throws HibernateException {
        return classMetadata.getPropertyValuesToInsert(entity, mergeMap, session);
    }

    @Override
    public Object[] getPropertyValues(Object entity) throws HibernateException {
        return classMetadata.getPropertyValues(entity, EntityMode.POJO);
    }

    public boolean implementsValidatable(EntityMode entityMode) {
        return classMetadata.implementsValidatable(entityMode);
    }

    public Serializable getIdentifier(Object entity, SessionImplementor session) {
        return classMetadata.getIdentifier(entity, session);
    }

    public void setPropertyValues(Object object, Object[] values, EntityMode entityMode) throws HibernateException {
        classMetadata.setPropertyValues(object, values, entityMode);
    }

    public Class getMappedClass(EntityMode entityMode) {
        return classMetadata.getMappedClass(entityMode);
    }

    @Override
    public int getVersionProperty() {
        return classMetadata.getVersionProperty();
    }

    @Override
    public boolean isMutable() {
        return classMetadata.isMutable();
    }

    @Override
    public boolean isInherited() {
        return classMetadata.isInherited();
    }

    @Override
    public boolean hasIdentifierProperty() {
        return classMetadata.hasIdentifierProperty();
    }

    @Override
    public boolean isVersioned() {
        return classMetadata.isVersioned();
    }

    @Override
    public boolean hasProxy() {
        return classMetadata.hasProxy();
    }

    public Type[] getPropertyTypes() {
        return classMetadata.getPropertyTypes();
    }

    @Override
    public boolean hasNaturalIdentifier() {
        return classMetadata.hasNaturalIdentifier();
    }

    public Object getVersion(Object object, EntityMode entityMode) throws HibernateException {
        return classMetadata.getVersion(object, entityMode);
    }

    public Type getIdentifierType() {
        return classMetadata.getIdentifierType();
    }


    public Object getPropertyValue(Object object, String propertyName) throws HibernateException {
        return classMetadata.getPropertyValue(object, propertyName, EntityMode.POJO);
    }
}
